Workflow Timeout Template
The Workflow Timeout template demonstrates how a workflow can automatically stop execution when an operation exceeds a predefined time limit. Timeouts protect workflows from hanging indefinitely due to slow services, stalled processes, or unexpected execution delays. This template introduces execution time limits into workflow orchestration.Purpose
This template demonstrates how to:- configure workflow timeouts
- detect excessively long execution
- stop stalled workflows
- improve workflow stability
- protect system resources
Workflow Structure
A timeout-enabled workflow follows the same execution path as a normal workflow.Execution Flow
While the workflow runs, elapsed time is measured.Timeout Trigger
If execution exceeds the configured limit:Timeout Policy
Timeout behavior is configured with a timeout policy. Example:Successful Execution
Normal execution completes before the timeout.Timeout Occurs
If execution takes too long:Long-Running Operations
Timeouts are especially useful when interacting with external systems. Examples include:- AI model inference
- external APIs
- document processing
- network communication
- database queries
- cloud services
Timeout vs Retry
Timeouts and retries work together but solve different problems.
A workflow may timeout before a retry is attempted.
Timeout vs Loop
Loops intentionally repeat workflow logic. Timeouts prevent loops from running forever.Scheduled Workflows
Timeouts are particularly important for scheduled workflows.Monitoring
Timeout events should be monitored in production. Useful information includes:- workflow identifier
- execution duration
- timeout threshold
- node executing
- provider involved
- retry count
Choosing a Timeout
Timeout values should reflect the expected workload. Examples:
Choose values that balance responsiveness with realistic execution time.
Best Practices
- Set realistic timeout limits.
- Use shorter limits for external services.
- Combine timeouts with retry policies.
- Monitor frequent timeout events.
- Avoid excessively long timeout values.
- Design workflows so interrupted operations can be safely restarted when appropriate.
Related Templates
The Timeout template works well alongside:- Workflow Retry
- Workflow Schedule
- Workflow Parallel
